package com.qf.springmvc.controller;

import com.qf.springmvc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;


@RestController
@RequestMapping("/json")
public class JsonController {

    @RequestMapping(value = "test1",produces = "text/html;charset=utf-8")

    public String test1(){

        return "ok,中文";
    }

    @RequestMapping("test2")

    public User test2(){
        User user = new User();
        user.setId(1);
        user.setName("AA");
        user.setAge(18);
        return user;
    }

    @RequestMapping("test3")

    public List<User> test3(){
        User user = new User();
        user.setId(1);
        user.setName("AA");
        user.setAge(18);
        User user2 = new User();
        user2.setId(2);
        user2.setName("BB");
        user2.setAge(20);
        return Arrays.asList(user,user2);
    }
}
